﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_DAL;
using Zor_Modes;

namespace Zor_Bll
{    
    /// <summary>
    /// 菜单管理
    /// create by zhl at 2012.3.24
    /// </summary>
    public class Sys_Navigations_Bll<T> where T : class
    {
       
         /// <summary>
        /// 查询菜单层级关系
        /// create zhl by 17-3-26
        /// </summary>
        /// <returns></returns>
        ///      
        public static List<T> SelectNavTree()
        {
            return Sys_Navigations_DAL<T>.SelectNavTree();
        }
        /// <summary>
        /// 菜单列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public static List<T> GetPageLists(int index, out int TotalCount)
        {
            return PagerHelp<T>.GetPagerList(index, "V_Sys_Navigations", "Nav_Id", out TotalCount);
        }
        /// <summary>
        /// 根据Id查询数据
        /// create zhl by 2017.3.24
        /// </summary>
        /// <returns></returns>
        public static T SelectPageListId(string nav_Id)
        {
            return Sys_Navigations_DAL<T>.SelectPageListId(nav_Id);
          
        }
        /// <summary>
        /// 菜单管理-新增
        /// create zhl by 2017.3.24
        /// </summary>
        /// <param name="navigation">菜单对象</param>
        /// <returns>执行结果：1 成功 0失败</returns>
        public static BaseAnswer InsertNavigations(Sys_Navigations navigation)
        {
            BaseAnswer bar = Sys_Navigations_DAL<T>.InsertNavigations(navigation);          
            if (bar.AnswerType != BaseAnswer.Answers.Error)
                bar.AnswerMeg = bar.AnswerType == BaseAnswer.Answers.Succee ? "增加成功！" : "新增失败，请检查菜单是否重复！";
            return bar;          

        }

        /// <summary>
        /// 菜单管理-修改
        /// create zhl by 2017.3.24
        /// </summary>
        /// <param name="navigation">菜单对象</param>
        /// <returns>执行结果：1 成功 0失败</returns>
        public static BaseAnswer UpdateNavigations(Sys_Navigations navigation)
        {
            BaseAnswer bar = Sys_Navigations_DAL<T>.UpdateNavigations(navigation);
            if (bar.AnswerType != BaseAnswer.Answers.Error)
                bar.AnswerMeg = bar.AnswerType == BaseAnswer.Answers.Succee ? "修改成功！" : "修改失败,请检查菜单是否重复！";
            return bar;
        }


        /// <summary>
        /// 删除菜单
        /// create zhl by 2017.3.24
        /// </summary>
        /// <param name="id">删除菜单的id</param>
        /// <returns>1正常 返回0</returns>
        public static BaseAnswer DeleteNavigations(int[] id)
        {
            BaseAnswer bar = Sys_Navigations_DAL<T>.DeleteNavigations(id);
            if (bar.AnswerType != BaseAnswer.Answers.Error)
                bar.AnswerMeg = bar.AnswerType == BaseAnswer.Answers.Succee ? "删除成功！" : "删除失败！";
            return bar;
        }


    }
}
